package com.fenghongzhang.test;

import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.ViewGroup;
import android.widget.ListView;

import androidx.appcompat.app.AppCompatActivity;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    private static final String TAG = "MainActivity";
    private ListView lv;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        lv = (ListView) findViewById(R.id.lv);

        List<String> list = new ArrayList<>();
        list.add("diyige1");
        list.add("diyige2");
        list.add("diyige3");
        list.add("diyige4");
        list.add("diyige");
        list.add("diyige");
        list.add("diyige");
        list.add("diyige");
        list.add("diyige");
        list.add("diyige");


        //解决listView的高度问题
        ViewGroup.LayoutParams layoutParams = lv.getLayoutParams();
        layoutParams.height = 300;
        lv.setLayoutParams(layoutParams);
        lv.setAdapter(new MyAdapter(list,this));

//        lv.setOnTouchListener(new View.OnTouchListener() {
//            @Override
//            public boolean onTouch(View v, MotionEvent event) {
//                //不允许父层拦截或干扰本控件
//                lv.getParent().requestDisallowInterceptTouchEvent(true);
//                return false;
//            }
//        });



    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        Log.i(TAG, "dispatchTouchEvent: ");
        return super.dispatchTouchEvent(ev);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        Log.i(TAG, "onTouchEvent: ");
        return super.onTouchEvent(event);
        
    }
}
